是否有一种简单的内置方法将2D Python列表打印为2D矩阵?
所以这:
[["A", "B"], ["C", "D"]]
Run Code Online (Sandbox Code Playgroud)
会变得像
A B
C D
Run Code Online (Sandbox Code Playgroud)
我找到了pprint模块,但它似乎没有做我想要的.
我有一个包含两个数据集的文件,我想将其作为两列读入 Python。
数据格式如下:
xxx yyy xxx yyy xxx yyy
Run Code Online (Sandbox Code Playgroud)
等等,所以我明白我需要以某种方式把它分开。我是 Python 的新手(并且对编程相对较新),所以到目前为止我一直在努力。目前我尝试使用:
def read(file):
column1=[]
column2=[]
readfile = open(file, 'r')
a = (readfile.read())
readfile.close()
Run Code Online (Sandbox Code Playgroud)
我将如何将读取的文件拆分为 column1 和 column2?
下面的代码将列出我的所有存储库。但是,有没有办法添加3列以包括创建日期,语言和类型(例如,“源” /“叉子”)?我正在使用PyGithub软件包。
from github import Github
g = Github("user_name", "passwd")
for repo in g.get_user().get_repos():
print(repo.name)
Run Code Online (Sandbox Code Playgroud)