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

Commite8d3bf7

Browse files
authored
Merge pull requestpowerexploit#11 from liamplm/new-script-get-ip
New script to get local and public IP address (IPv4)
2 parents2e564b7 +53fb4d5 commite8d3bf7

File tree

3 files changed

+63
-22
lines changed

3 files changed

+63
-22
lines changed

‎Scripts/get_ip_address.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/local/bin/python3
2+
# return local and public ip address
3+
4+
importsocket
5+
importrequests
6+
7+
defget_local_IP():
8+
try:
9+
host_name=socket.gethostname()
10+
local_ip=socket.gethostbyname(host_name)
11+
print("Local IP: ",local_ip)
12+
except:
13+
print("Unable to get Local IP")
14+
15+
16+
defget_public_IP():
17+
try:
18+
public_ip=requests.get('http://www.icanhazip.com').content.decode()
19+
print("Public IP: ",public_ip)
20+
except:
21+
print("Unable to get Public IP")
22+
23+
24+
get_local_IP()
25+
get_public_IP()

‎Scripts/magic8Ball.py‎

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
#!/usr/local/bin/python3
2-
#return statement
2+
#return statement
33
importrandom
4-
defgetAnswer(answerNumber):
5-
ifanswerNumber==1:
6-
return'It is certain'
7-
elifanswerNumber==2:
8-
return'It is decidedly so'
9-
elifanswerNumber==3:
10-
return'Yes'
11-
elifanswerNumber==4:
12-
return'Reply hazy try again'
13-
elifanswerNumber==5:
14-
return'Ask again later'
15-
elifanswerNumber==6:
16-
return'Concentrate and ask again'
17-
elifanswerNumber==7:
18-
return'My reply is no'
19-
elifanswerNumber==8:
20-
return'Outlook not so good'
21-
elifanswerNumber==9:
22-
return'Very doubtful'
234

24-
r=random.randint(1,9)
5+
6+
possibleAnswer= [
7+
'It is certain',
8+
'It is decidedly so',
9+
'Yes',
10+
'Reply hazy try again',
11+
'Ask again later',
12+
'Concentrate and ask again',
13+
'My reply is no',
14+
'Outlook not so good',
15+
'Very doubtful'
16+
]
17+
18+
defgetAnswer(answerIndex):
19+
returnpossibleAnswer[answerIndex]
20+
21+
22+
r=random.randint(0,8)
2523
fortune=getAnswer(r)
2624
print(fortune)
27-

‎Scripts/rand_range.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/local/bin/python3
2+
# return random number in range
3+
importrandom
4+
importsys
5+
6+
try:
7+
rand_min,rand_max=int(sys.argv[1]),int(sys.argv[2])
8+
9+
random_int=random.randint(rand_min,rand_max)
10+
print('random number:',random_int)
11+
12+
exceptValueError:
13+
print('only number like value are valid for min, max')
14+
15+
exceptIndexError:
16+
print('''
17+
No min or max number was supplied
18+
rand_range.py <min> <max>
19+
''')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp