Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit58aa7b5

Browse files
authored
Merge pull requestpowerexploit#9 from xyzricky/master
Excel generator added
2 parentsa444d31 +a525d1d commit58aa7b5

File tree

2 files changed

+62
-4
lines changed

2 files changed

+62
-4
lines changed

‎Scripts/excel.py‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""
2+
In this script we're going to create a simple excel file with 3(Three) columns
3+
Name | Age | Gender
4+
"""
5+
6+
7+
8+
# xlwt module helps make a new excel file
9+
importxlwt
10+
11+
# create a dictionary with information
12+
DATA_= {
13+
'Person1' : {
14+
'Name' :'Bill Gates',
15+
'Age' :63,
16+
'Gender' :'Male'
17+
},
18+
'Person2' : {
19+
'Name' :'Sheryl Sandberg',
20+
'Age' :50,
21+
'Gender' :'Female'
22+
},
23+
'Person3' : {
24+
'Name' :'Tim Cook',
25+
'Age' :58,
26+
'Gender' :'Male'
27+
},
28+
}
29+
30+
# first create a new workbook
31+
workbook=xlwt.Workbook()
32+
33+
# add a new sheet to the workbook
34+
sheet=workbook.add_sheet('Sheet1')
35+
36+
# create columns
37+
sheet.write(0,0,'Name')
38+
sheet.write(0,1,'Age')
39+
sheet.write(0,2,'Gender')
40+
41+
42+
# we will keep counter running until we loop through all the persons inside DATA_
43+
counter=1
44+
45+
# now lets get the details from the DATA_ dict and insert them into our excel sheet
46+
fork,vinDATA_.items():
47+
sheet.write(counter,0,v['Name'])
48+
sheet.write(counter,1,v['Age'])
49+
sheet.write(counter,2,v['Gender'])
50+
51+
# now increment the counter each time
52+
# this will make sure that information are added on new line for each person
53+
counter+=1
54+
55+
# time to save the workbook
56+
workbook.save('details.xls')

‎Scripts/myPets.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/python3
2+
23
mypets= ['Zophie','Poka','fat-tail']
3-
print('enter a per name:')
4-
name=input()
4+
5+
name=input('Enter pet name: ')
6+
57
ifnamenotinmypets:
6-
print('I dont have a pet name'+name )
8+
print('I dont have a pet name"%s"'%name )
79
else:
8-
print(name+'is my pet')
10+
print(name+',is my pet')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp