Best Python code snippet using playwright-python
robot.py
Source:robot.py  
...50                        if min > 1600: #uncertern51                                n_unknow = n_unknow + 152                                m[y][x] = -153        print(n_unknow)54        def test_click(l,m,c,x,y,px,py):55                if c==-1 or x<0 or y<0 or px<0 or py<0:56                        return57                if m[x][y] == c:58                        l.append((x,y,px,py))59                        #print("(%d,%d)->(%d,%d)"%(x,y,px,py))60        l = []61        for x in range(8):62                for y in range(7,-1,-1):63                        c = m[x][y]64                        try:65                                if m[x+1][y] == c:66                                        test_click(l,m,c,x+3,y,x+2,y)67                                        test_click(l,m,c,x+2,y-1,x+2,y)68                                        test_click(l,m,c,x+2,y+1,x+2,y)69                                if y > 0 and m[x][y-1] == c:70                                        test_click(l,m,c,x,y-3,x,y-2)71                                        test_click(l,m,c,x-1,y-2,x,y-2)72                                        test_click(l,m,c,x+1,y-2,x,y-2)73                                if m[x+2][y] == c:74                                        test_click(l,m,c,x+1,y+1,x+1,y)75                                        test_click(l,m,c,x+1,y-1,x+1,y)76                                if y > 1 and m[x][y-2] == c:77                                        test_click(l,m,c,x-1,y-1,x,y-1)78                                        test_click(l,m,c,x+1,y-1,x,y-1)79                        except IndexError:80                                pass81        print('len:',len(l))82        if not len(l):83                zero_count = zero_count + 184                if zero_count == 3:85                        win32api.keybd_event(90,0,0,0) #zé®ä½ç æ¯90  86                        win32api.keybd_event(90,0,win32con.KEYEVENTF_KEYUP,0)  87                        print('z')88                        zero_count=089                continue90        else:91                zero_count = 092                def pick(list,last):...data_preprocess2.py
Source:data_preprocess2.py  
1import numpy as np2import pandas as pd3import random4from tqdm import tqdm5from models import reduce_mem as rm6seed = 20217data_path = './tcdata'8np.random.seed(seed)9random.seed(seed)10def get_user_items_list(all_click):11    train_user_ids = all_click['user_id'].unique()12    all_click = all_click[all_click['label'] == 1]13    all_2_tianchi = {}14    for u in train_user_ids:15        all_2_tianchi[u] = list(all_click[all_click['user_id'] == u]['click_article_id'])16    all_2_tianchi_list = []17    for user, items in tqdm(all_2_tianchi.items()):18        if len(items) == 0:19            continue20        all_2_tianchi_list.append([user, *items])21    return all_2_tianchi_list22def get_sample_2_tianchi(data_path):23    columns_name = ['user_id', 'click_article_id', 'label']24    train_click = pd.read_csv(data_path + '/train/train_all_click_sample.csv', sep=' ')25    train_click.columns = columns_name26    train_click = rm.reduce_mem(train_click)27    test_click = pd.read_csv(data_path + '/valid/valid_all_click_sample.csv', sep=' ')28    test_click.columns = columns_name29    test_click = rm.reduce_mem(test_click)30    train_2_tianchi_list = get_user_items_list(train_click)31    test_2_tianchi_list = get_user_items_list(test_click)32    return train_2_tianchi_list, test_2_tianchi_list33def get_df_2_tianchi(data_path):34    columns_name = ['user_id', 'click_article_id', 'label']35    train_click = pd.read_csv(data_path + '/train/train_all_click_df.csv', sep=' ')36    train_click.columns = columns_name37    train_click = rm.reduce_mem(train_click)38    test_click = pd.read_csv(data_path + '/valid/valid_all_click_df.csv', sep=' ')39    test_click.columns = columns_name40    test_click = rm.reduce_mem(test_click)41    train_2_tianchi_list = get_user_items_list(train_click)42    test_2_tianchi_list = get_user_items_list(test_click)43    return train_2_tianchi_list, test_2_tianchi_list44# train_2_tianchi_list_sample, test_2_tianchi_list_sample = get_sample_2_tianchi(data_path)45# with open("./tcdata/train/train_2_tianchi_sample.csv", "w") as f:46#     for i in range(len(train_2_tianchi_list_sample)):47#         for j in train_2_tianchi_list_sample[i]:48#             f.write(str(j) + " ")49#         f.write("\n")50#51# with open("./tcdata/test/test_2_tianchi_sample.csv", "w") as f:52#     for i in range(len(test_2_tianchi_list_sample)):53#         for j in test_2_tianchi_list_sample[i]:54#             f.write(str(j) + " ")55#         f.write("\n")56train_2_tianchi_list_df, test_2_tianchi_list_df = get_df_2_tianchi(data_path)57with open("./tcdata/train/train_2_tianchi_df.csv", "w") as f:58    for i in range(len(train_2_tianchi_list_df)):59        for j in train_2_tianchi_list_df[i]:60            f.write(str(j) + " ")61        f.write("\n")62with open("./tcdata/test/test_2_tianchi_df.csv", "w") as f:63    for i in range(len(test_2_tianchi_list_df)):64        for j in test_2_tianchi_list_df[i]:65            f.write(str(j) + " ")...03.py
Source:03.py  
1"""2https://www.cnblogs.com/alexkn/p/6980400.html3"""4import click5@click.command()6@click.option('--count', default=1, help='Number of greetings.')7@click.option('--name', prompt='Your name', help='The person to greet.')8def hello(count, name):9    """Simple program that greets NAME for a total of COUNT times."""10    for x in range(count):11        click.echo('Hello %s!' % name)12if __name__ == '__main__':13    hello()14"""15(venv3) [root@lanzhiwang-centos7 test_click]# python 03.py --count=316Your name: lanzhiwang17Hello lanzhiwang!18Hello lanzhiwang!19Hello lanzhiwang!20(venv3) [root@lanzhiwang-centos7 test_click]#21(venv3) [root@lanzhiwang-centos7 test_click]# python 03.py --count=3 --name=lanzhiwang22Hello lanzhiwang!23Hello lanzhiwang!24Hello lanzhiwang!25(venv3) [root@lanzhiwang-centos7 test_click]#26(venv3) [root@lanzhiwang-centos7 test_click]# python 03.py --help27Usage: 03.py [OPTIONS]28  Simple program that greets NAME for a total of COUNT times.29Options:30  --count INTEGER  Number of greetings.31  --name TEXT      The person to greet.32  --help           Show this message and exit.33(venv3) [root@lanzhiwang-centos7 test_click]#...02.py
Source:02.py  
1"""2https://www.jianshu.com/p/572251c91dd03"""4import click5@click.group()6def first():7    print("hello world")8@click.command()9@click.option("--name", help="the name")10def second(name):11    print("this is second: {}".format(name))12@click.command()13def third():14    print("this is third")15first.add_command(second)16first.add_command(third)17if __name__ == '__main__':18    first()19"""20(venv3) [root@lanzhiwang-centos7 test_click]# python 02.py21Usage: 02.py [OPTIONS] COMMAND [ARGS]...22Options:23  --help  Show this message and exit.24Commands:25  second26  third27(venv3) [root@lanzhiwang-centos7 test_click]#28(venv3) [root@lanzhiwang-centos7 test_click]# python 02.py second29hello world30this is second: None31(venv3) [root@lanzhiwang-centos7 test_click]#32(venv3) [root@lanzhiwang-centos7 test_click]# python 02.py third33hello world34this is third35(venv3) [root@lanzhiwang-centos7 test_click]#36(venv3) [root@lanzhiwang-centos7 test_click]# python 02.py second --name hh37hello world38this is second: hh39(venv3) [root@lanzhiwang-centos7 test_click]#...LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!
