Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python PyCharm警告字符串和字节连接,但一切都是字符串_Python_String_Pycharm_Concatenation - Fatal编程技术网

Python PyCharm警告字符串和字节连接,但一切都是字符串

Python PyCharm警告字符串和字节连接,但一切都是字符串,python,string,pycharm,concatenation,Python,String,Pycharm,Concatenation,PyCharm警告我: days = os.listdir(os.path.join(os.path.dirname(__file__), src)) day = days[0] mystring = day.split('.')[0] + ';' + str(entering) 应为“bytes”类型,改为“str” 但对我来说一切似乎都很顺利。。 不管怎么说,它是有效的,但这些警告让我怀疑。有什么提示吗 编辑 添加更多细节:Pycharm是Linux中的2019.3.3版。输入是int,s

PyCharm警告我:

days = os.listdir(os.path.join(os.path.dirname(__file__), src))
day = days[0]
mystring = day.split('.')[0] + ';' + str(entering)
应为“bytes”类型,改为“str”

但对我来说一切似乎都很顺利。。 不管怎么说,它是有效的,但这些警告让我怀疑。有什么提示吗

编辑 添加更多细节:Pycharm是Linux中的2019.3.3版。输入是int,src是来自以下路径的路径:

p = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description="")
p.add_argument('-src', dest='source', action='store', default='results', help='source path')

args = p.parse_args()
src = args.source

如果查看
os.listdir
定义,您可以阅读以下部分:

如果路径是bytes类型(直接或间接通过PathLike接口),则返回的文件名也将是bytes类型;在所有其他情况下,它们将为str型


我认为这是
os.path.join
的间接原因,因为它返回实现
PathLike
接口的对象。我认为PyCharm假定,
os.path.join
会以某种方式返回字节。最简单的方法就是使用
str(os.path.join(os.path.dirname(\uuuu file\uuuuu),src))
(虽然它已经是一个str)

什么是
src
输入
?@hiroprotagent用字符串文字替换
src
str(输入)
,这似乎就是其中之一中的“假阳性”错误pycharm@DeepSpace哦,是的,可以复制。错误在最后一行(…这可能是补充问题的有用信息)。无法在Linux上的pycharm community 2019.3.2中复制