我首先尝试为它运行基本的 pip install 命令:
C:\Program Files (x86)\Python35-32>pip install lxml
Collecting lxml
Using cached lxml-3.6.4.tar.gz
Building wheels for collected packages: lxml
Running setup.py bdist_wheel for lxml ... error
Complete output from command "c:\program files (x86)\python35-32\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\Djidiouf\\AppData\\Local\\Temp\\pip-build-ovqa6ncd\\lxml\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\Djidiouf\AppData\Local\Temp\tmp9hzx5gztpip-wheel- --python-tag cp35:
Building lxml version 3.6.4.
Building without Cython.
ERROR: b"'xslt-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"
** make sure the development packages of libxml2 and …Run Code Online (Sandbox Code Playgroud) 我有一些Tython函数要插入文件中.插入多行本身可以很好地使用变量和一些\n,但不保留缩进.因为它是Python代码,这是一个大问题,代码无法正常工作.
这是我尝试过的:
cat sed-insertlines.sh
#!/bin/bash
read -r -d '' lines_to_insert << 'EOF'
def string_cleanup(x, notwanted):\n
for item in notwanted:\n
x = re.sub(item, '', x)\n
return x\n
EOF
lines_to_insert=$(echo ${lines_to_insert} )
sed -i "/import re # Regular Expression library/a $lines_to_insert" sed-insertlines.txt
Run Code Online (Sandbox Code Playgroud)
但是我最终得到的是cat sed-insertlines.txt:
#!/bin/python
import re # Regular Expression library
def string_cleanup(x, notwanted):
for item in notwanted:
x = re.sub(item, '', x)
return x
def string_replace(i_string, pattern, newpattern):
string_corrected = re.sub(pattern, newpattern, i_string)
return string_corrected
Run Code Online (Sandbox Code Playgroud)
线条在那里,但压痕消失了.