Socket API 函数和方法有下面这些:
-
socket()
-
bind()
-
listen()
//Passing values from Stateless Widgets to other Stateless Widgets and Making New widgets to write cleaner code and remove repetitive code | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( |
p1_call = raw_input("Player 1, Enter rock/paper/scissors: ") | |
p2_call = raw_input("Player 2, Enter rock/paper/scissors: ") | |
def rock_paper_scissors(player_1, player_2): | |
a_list = ["rock", "paper", "scissors"] | |
while player_1 not in a_list or player_2 not in a_list: | |
print "Invalid input. Please give a valid input." | |
player_1 = raw_input("Player 1, Enter rock/paper/scissors: ") | |
player_2 = raw_input("Player 2, Enter rock/paper/scissors: ") |
#!/usr/bin/python | |
import socket #for sockets | |
import sys #for exit | |
try: | |
#create an AF_INET, STREAM socket (TCP) | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
except socket.error, msg: | |
print 'Failed to create socket. Error code: ' + str(msg[0]) + ' , Error message : ' + msg[1] |
#!/usr/bin/env python3 | |
# coding: utf-8 | |
#1安装python3 | |
#2命令行 执行 pip3 install -i https://pypi.doubanio.com/simple/ -U wxpy | |
#3在终端中显示登陆二维码,需要安装 pillow 模块 (pip3 install pillow)。 | |
import datetime | |
import logging |
# -*- coding: utf-8 -*- | |
import locale | |
import random | |
import _winreg | |
import subprocess | |
import socket | |
import time | |
SUBKEY = r'SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0001' |
import socket | |
import fcntl | |
import struct | |
def getHwAddr(ifname): | |
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', ifname[:15])) | |
return ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1] |
import ctypes | |
import socket | |
import struct | |
def get_macaddress(host): | |
""" Returns the MAC address of a network host, requires >= WIN2K. | |
""" | |
# Check for api availability | |
try: |
#!/bin/env python | |
# -*- coding: utf-8 -*- | |
# This program is free software. It comes without any warranty, to | |
# the extent permitted by applicable law. You can redistribute it | |
# and/or modify it under the terms of the Do What The Fuck You Want | |
# To Public License, Version 2, as published by Sam Hocevar. See | |
# http://sam.zoy.org/wtfpl/COPYING for more details. | |
import asyncore |
# The Kick light - Python interface to control it via the Wireless api. | |
# | |
# Before using this class, it's currently required for you to connect | |
# your kick to the device running this, using AD-HOC. If the connection drops, | |
# you have Wi-Fi drivers that do not support AD-HOC mode. | |
# | |
# Changing colour will have no effect unless the light is visible. | |
import binascii | |
import socket |