Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/297.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/8/python-3.x/16.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 3.8.0-在新行上打印带有变量值的自文档表达式_Python_Python 3.x_Pandas_F String_Python 3.8 - Fatal编程技术网

python 3.8.0-在新行上打印带有变量值的自文档表达式

python 3.8.0-在新行上打印带有变量值的自文档表达式,python,python-3.x,pandas,f-string,python-3.8,Python,Python 3.x,Pandas,F String,Python 3.8,Python 3.8.0允许使用=,例如:print(f'{myvar=}')对表达式进行自文档化和调试 是否可以在新行上打印输出?这对于具有多行输出(如数据帧)的变量非常有用 e、 g 如果将f字符串设为三重引号,则可以在=后面添加一个换行符: df = pd.DataFrame({'animal':['alligator', 'bee', 'falcon', 'lion', 'monkey', 'parrot', 'shark', 'whale', 'ze

Python 3.8.0允许使用
=
,例如:
print(f'{myvar=}')
对表达式进行自文档化和调试

是否可以在新行上打印输出?这对于具有多行输出(如数据帧)的变量非常有用

e、 g


如果将f字符串设为三重引号,则可以在
=
后面添加一个换行符:

df = pd.DataFrame({'animal':['alligator', 'bee', 'falcon', 'lion',
                  'monkey', 'parrot', 'shark', 'whale', 'zebra']})

print(f'''{df=
}''')
df = pd.DataFrame({'animal':['alligator', 'bee', 'falcon', 'lion',
                  'monkey', 'parrot', 'shark', 'whale', 'zebra']})

print(f'''{df=
}''')