Print a string
In [1]:
import random
import sys
import os
import socket
import time
hosName = (socket.gethostname())
socket.getaddrinfo('74.50.51.32' , 9999)
Out[1]:
In [42]:
import subprocess
In [59]:
callmds = ('ssh', 'drhealsgood@74.50.51.32')
gittest = ('git', 'log')
In [63]:
subprocess.check_output(gittest)
Out[63]:
In [60]:
subprocess.Popen(gittest, bufsize=5)
Out[60]:
In [3]:
socket.getservbyport(10000)
Out[3]:
In [6]:
socket.socketpair()
Out[6]:
In [7]:
curtimez = time.strftime('%c')
In [8]:
s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 12345 # Reserve a port for your service.
s.bind((host, port)) # Bind to the port
s.listen(5) # Now wait for client connection.
while True:
c, addr = s.accept() # Establish connection with client.
print 'Got connection from', addr
c.send('Thank you for connecting')
c.close() # Close the connection
In [9]:
addrinfos = raw_input('Website to get ip: ')
In [10]:
sitesoc = socket.getaddrinfo(addrinfos, 80)
In [11]:
eleone = sitesoc[0]
In [12]:
print eleone
In [13]:
elz = eleone[4]
In [14]:
print elz[0]
In [15]:
len(sitesoc)
In [16]:
ipstr = str(elz[0])
In [17]:
greet = ('Hello ' + hosName + ' currently it is ' + curtimez + ' IP address: ' + ipstr)
In [18]:
print greet
In [19]:
print ('hello world!')
Some basic math
In [20]:
print (3 * 5)
Variables
In [21]:
x = ('Hamilton Computer Club! ')
In [22]:
print x
Add some math into that
In [23]:
print x * 6
In [24]:
i = ('bleh bleh bleh')
In [25]:
print i
In [26]:
upi = str.upper(i)
In [26]:
In [27]:
import requests
In [27]:
In [28]:
print newci[raci]
In [29]:
print upi
In [30]:
print upi + i
modules are fun
In [31]:
import random
In [32]:
newRand = random.randint(0,666)
In [33]:
upi * newRand
Out[33]:
In [34]:
import requests
I used requests to get website data
In [35]:
newSite = requests.get('http://tlcxpress.ac.nz/tlc-website/notices/')
In [36]:
newFile = open('site','w')
In [37]:
newFile.close()
In [38]:
import os
In [39]:
getHost = os.path
In [40]:
for d in getHost:
In [ ]:
In [35]:
import antigravity
In [36]:
antigravity.webbrowser.
Out[36]:
In [37]:
from __future__ import braces
In [43]:
import antigravity
def main():
antigravity.webbrowser.subprocess
if __name__ == '__main__':
main()
In [44]:
main()
In [45]:
print main()
In [ ]: