当我执行此代码时,出现以下错误:
import socket
s=socket.socket()
s.connect(("data.pr4e.org",80))
cmd='GET http://data.pr4e.org/romeo.txt HTTP/1.0\n\n'.encode()
s.send(cmd)
while True:
data=s.recv(512)
if (len(data)<1):
break
print(data.decode())
s.close()
Run Code Online (Sandbox Code Playgroud)
错误:
import socket
s=socket.socket()
s.connect(("data.pr4e.org",80))
cmd='GET http://data.pr4e.org/romeo.txt HTTP/1.0\n\n'.encode()
s.send(cmd)
while True:
data=s.recv(512)
if (len(data)<1):
break
print(data.decode())
s.close()
Run Code Online (Sandbox Code Playgroud)
当这个代码在终端上输入时,它工作得很好。
我不明白我做错了什么。
我正在使用以下for循环代码来打印星形图案,并且代码工作得很好。
这是我的代码:
for i in range(1,6):
for j in range(i):
print("*", end=" ")
print()
Run Code Online (Sandbox Code Playgroud)
此代码显示:
*
* *
* * *
* * * *
* * * * *
Run Code Online (Sandbox Code Playgroud)
现在,我的问题是如何打印输出,如下所示:
*
* *
* * *
* * * *
* * * * *
Run Code Online (Sandbox Code Playgroud) 根据此更新,VS Code 应该在>键入结束标签时自动关闭标签。我的似乎不会这样做(我使用的是 v1.19)。
我还尝试安装 Jun Han 制作的软件包,它也应该执行此操作,但它不起作用。有什么技巧可以让这个功能发挥作用吗?
启用的扩展有:
我有一个从 CSV 文件读取的 pyspark 数据帧,该文件具有一个包含十六进制值的值列。
| date | part | feature | value" |
|----------|-------|---------|--------------|
| 20190503 | par1 | feat2 | 0x0 |
| 20190503 | par1 | feat3 | 0x01 |
| 20190501 | par2 | feat4 | 0x0f32 |
| 20190501 | par5 | feat9 | 0x00 |
| 20190506 | par8 | feat2 | 0x00f45 |
| 20190507 | par1 | feat6 | 0x0e62300000 |
| 20190501 | par11 | feat3 | 0x000000000 |
| 20190501 …Run Code Online (Sandbox Code Playgroud) 我尝试在我的电脑上安装 SSL,但不断收到以下错误。我在这里错过了一些非常基本的东西吗?我尝试升级我的 pip 并升级 setuptools,但似乎没有任何效果。任何帮助将不胜感激。
C:\Users\Michael\PycharmProjects\py4e>pip3 install ssl
Collecting ssl
Using cached https://files.pythonhosted.org/packages/83/21/f469c9923235f8c36d5
fd5334ed11e2681abad7e0032c5aba964dcaf9bbb/ssl-1.16.tar.gz
ERROR: Complete output from command python setup.py egg_info:
ERROR: Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\MICHAE~1\AppData\Local\Temp\pip-install-qtieo4so\ssl\setup.
py", line 33
print 'looking for', f
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('loo
king for', f)?
----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in C:\Users\M
ICHAE~1\AppData\Local\Temp\pip-install-qtieo4so\ssl\
Run Code Online (Sandbox Code Playgroud) 我正在创建一个 Android 应用程序。问题是当我按下按钮并将数据传递给新数组时,它会变黑并给我这个错误:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.util.ArrayList.add (java.lang.Object) 'on a null object reference
Run Code Online (Sandbox Code Playgroud)
通过调试,它给了我一些字符串:
mExampleList.add(Ticket)
Run Code Online (Sandbox Code Playgroud)
我的 ExampleAdapter 类:
public class ExampleAdapter extends RecyclerView.Adapter<ExampleAdapter.ExampleViewHolder>{
private ArrayList<ExampleItemRecyclerview>mExampleList;
public class ExampleViewHolder extends RecyclerView.ViewHolder{
public TextView mTextticket;
public TextView mTextredattore;
public TextView mTexttarga;
public TextView mTextdataA;
public TextView mTextmanutenzioneG;
public TextView mTextdataC;
public ExampleViewHolder(View itemView) {
super(itemView);
mTextticket = itemView.findViewById(R.id.txt_ticket);
mTextredattore = itemView.findViewById(R.id.txt_redattore);
mTexttarga = itemView.findViewById(R.id.txt_targa);
mTextdataA = itemView.findViewById(R.id.txt_dataA);
mTextmanutenzioneG = itemView.findViewById(R.id.txt_materiale);
mTextdataC = itemView.findViewById(R.id.txt_dataC);
}
}
public …Run Code Online (Sandbox Code Playgroud) 我有这样的文件夹结构,每次尝试使用相对导入时,都会出现错误
\n\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 graphics\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __init__.py\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 A\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __init__.py\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 grok.py\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 spam.py\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 B\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __init__.py\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 bar.py\n\n\nspam.py/\n def func():\n pass\nbar.py/\n def f():\n pass\nRun Code Online (Sandbox Code Playgroud)\n\n所有这些代码都在 grok.py 中进行了测试:
\n\nfrom . import spam\n# ImportError: cannot import name 'spam'\n\nfrom .spam import func\n# ModuleNotFoundError: No module named '__main__.spam'; '__main__' \nis not a package\n\nfrom ..B import bar\n# ValueError: attempted relative import beyond top-level package\nRun Code Online (Sandbox Code Playgroud)\n\n以下代码均不会导致任何错误:
\n\nfrom graphics.A import spam\nfrom graphics.A.spam import func\nfrom graphics.B import bar\nfrom graphics.B.bar …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下命令在 Ubuntu 终端上安装monkeytype:
pip install monkeytype
Run Code Online (Sandbox Code Playgroud)
但我收到一条错误消息:
Command "python setup.py egg_info" failed with error code 1
Run Code Online (Sandbox Code Playgroud)
这是完整的日志:
bash-4.3$ pip install monkeytype
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting monkeytype
Using cached https://files.pythonhosted.org/packages/5f/59/43bc6e44d69bd268e545fdfacdd6866362aca57ac894bbc3177b5455c06a/MonkeyType-18.2.0.tar.gz
Collecting retype (from monkeytype)
Using cached https://files.pythonhosted.org/packages/6e/da/ca9f5560f051d2ed79a52de1170903e3ff8ad011cff56c65abfcff38d372/retype-17.12.0.tar.gz
ERROR: Complete output from command python setup.py egg_info:
ERROR: …Run Code Online (Sandbox Code Playgroud) 以下终端日志供您参考
Traceback (most recent call last):
File "src/Utilities_test/test_cases_csv.py", line 39, in <module>
report_status = email_reporter(html_report_dir.split('/', 1)[-1])
File "src/Utilities_support/report_email.py", line 27, in email_reporter for item in conf_data.items(conf):
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 857, in items
return [(option, value_getter(option)) for option in d.keys()]
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 857, in <listcomp>
return [(option, value_getter(option)) for option in d.keys()]
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 854, in <lambda>
section, option, d[option], d)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 394, in before_get
self._interpolate_some(parser, option, L, value, section, defaults, 1)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/configparser.py", line 444, in …Run Code Online (Sandbox Code Playgroud) import wikipedia
print (wikipedia.summary("Wikipedia"))
Run Code Online (Sandbox Code Playgroud)
在这段代码中,我遇到了这个问题:
AttributeError: 模块“wikipedia”没有属性“summary”
python ×6
python-3.x ×4
pip ×2
android ×1
appium ×1
arraylist ×1
installation ×1
java ×1
pyspark ×1
python-3.6 ×1
python-3.7 ×1
sockets ×1
ssl ×1
wikipedia ×1