-
peng111说:
python怎么做三50列50行表格
§ Code
#使用Python的模块printtable
from printtable import PrintTable#定义列标题
col_titles=['col1','col2','col3','col4','col5','col6','col7','col8','col9','col10',
'col11','col12','col13','col14','col15','col16','col17','col18','col19','col20',
'col21','col22','col23','col24','col25','col26','col27','col28','col29','col30',
'col31','col32','col33','col34','col35','col36','col37','col38','col39','col40',
'col41','col42','col43','col44','col45','col46','col47','col48','col49','col50']#定义表格内容
table_data = [
['1','2','3','4','5','6','7','8','9','10',
'11','12','13','14','15','16','17','18','19','20',
'21','22','23','24','25','26','27','28','29','30',
'31','32','33','34','35','36','37','38','39','40',
'41','42','43','44','45','46','47','48','49','50'],
['1','2','3','4','5','6','7','8','9','10',
'11','12','13','14','15','16','17','18','19','20',
'21','22','23','24','25','26','27','28','29','30',
'31','32','33','34','35','36','37','38','39','40',
'41','42','43','44','45','46','47','48','49','50'],
['1','2','3','4','5','6','7','8','9','10',
'11','12','13','14','15','16','17','18','19','20',
'21','22','23','24','25','26','27','28','29','30',
'31','32','33','34','35','36','37','38','39','40',
'41','42','43','44','45','46','47','48','49','50'],
['1','2','3','4','5','6','7','8','9','10',
'11','12','13','14','15','16','17','18','19','20',
'21','22','23','24','25','26','27','28','29','30',
'31','32','33','34','35','36','37','38','39','40',
'41','42','43','44','45','46','47','48','49','50'],
['1','2','3','4','5','6','7','8','9','10',
'11','12','13','14','15','16','17','18','19','20',
'21','22','23','24','25','26','27','28','29','30',
'31','32','33','34','35','36','37','38','39','40',
'41','42','43','44','45','46','47','48','49','50'],
['1','2','3','4','5','6','7','8','9','10',
'11','12','13','14','15','16','17','18','19','20',
'21','22','23','24','25','26','27','28','29','30',
'31','32','33','34','35','36','37','38','39','40',
'41','42','43','44','45','46','47','48','49','50'],
['1','2','3','4','5','6','7','8','9','10',
'11','12','13','14','15','16','17','18','19','20',
'21','22','23','24','25','26','27','28','29','30',
'31','32','33','34','35','36','37','38','39','40',
'41','42','43','44','45','46','47','48','49','50'],
['1','2','3','4','5','6','7','8','9','10',
'11','12','13','14','15','16','17','18','19','20',
'21','22','23','24','25','26','27','28','29','30',
'31','32','33','34','35','36','37','38','39','40',
'41','42','43','44','45','46','47','48','49','50'],
['1','2','3','4','5','6','7','8','9','10',
'11','12','13','14','15','16','17','18','19','20',
'21','22','23','24','25','26','27','28','29','30',
'31','32','33','34','35','36','37','38','39','40',
'41','42','43','44','45','46','47','48','49','50'],
['1','2','3','4','5','6','7','8','9','10',
'11','12','13','14','15','16','17','18','19','20',
'21','22','23','24','25','26','27','28','29','30',
'31','32','33','34','35','36','37','38','39','40',
'41','42','43','44','45','46','47','48','49','50']
]#创建表格
table = PrintTable(col_titles)#添加表格内容
table.add_rows(table_data)#打印表格
table.print_table()§ Output
stdout : ['+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+----...----+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+\n', 'Total rows: 10\n']
§ END OF DOC
-
marlkiller说:
java 支持携程吗? 请提供一份示例
是的,Java 支持使用携程来实现多线程编程。下面是一个简单的 Java 携程示例:
public class MyThread implements Runnable{
public void run(){
System.out.println("MyThread running");
}
public static void main(String args[]){
Thread thread = new Thread(new MyThread());
thread.start();
}
} -
marlkiller说:
new Thread 是线程还是携程?
new Thread 是线程
-
marlkiller说:
如果 new Thread 是线程, 那么如何使用 Java 实现携程呢?
Java 并没有提供原生的携程支持,但是可以使用第三方库来实现,比如Quasar框架。Quasar通过使用Java语言支持携程,使用@Co-routine注解可以实现携程。以下是一个简单的例子:
import co.paralleluniverse.fibers.Suspendable;
public class MyCoRoutine {
@Suspendable
public void run() {
System.out.println("Co-routine Started!");
// Do something here
System.out.println("Co-routine Ended!");
}
}