python-问题解决
- can’t multiply sequence by non-int of type ‘str’
- invalid decimal literal
- ValueError: math domain error
- missing whitespace after ‘,’
- missing whitespace around operator
- no newline at end of file
- PEP 8: expected 2 blank lines after class or function definition, found 1
- This dictionary creation could be rewritten as a dictionary literal
(标题)can’t multiply sequence by non-int of type ‘str’
通过键盘输入返回值的类型是字符串,要进行数学运算要强制转换
//像java这样:int a在这里是无效语法
//可以这样(两种方式都可以)
1:a = int(input('请输入乘数:'))
2:int(a)*int(b)
(标题)invalid decimal literal
翻译了一下:十进制文本无效
这里犯了个打错,变量的命名规则呀,不能数字开头
(标题)ValueError: math domain error
报错
原因:某些操作不符合数学定义,如对负数取对数,对负数开平方
问题出现在这里:
取值为10,20,30的时候,里面是负数,不符合
(标题)missing whitespace after ‘,’
解决方法:逗号后面加个空格
(标题)missing whitespace around operator
解决方法:=左右各加一个空格
(标题)no newline at end of file
看到一个 warning:no newline at end of file
文件每一行都以换行结束,只需要在文件结尾回车即可
具体原因:
避免include文件时,展开后与后面的文件连为一行,造成错误。
(标题)PEP 8: expected 2 blank lines after class or function definition, found 1
意思是“有两个空白行,但是没有发现。”
在声明函数的那一行的上方必须有两行的空行,否则便出现这个情况。
(标题)This dictionary creation could be rewritten as a dictionary literal
之所以出现这个的原因,是因为这两句可以合并
更多其他关闭这个提示:https://stackoverflow.com/questions/8406242/why-does-pycharms-inspector-complain-about-d
还没有评论,来说两句吧...