perl

再见 Python,Hello Julia!

核能气质少年 提交于 2020-07-27 08:42:51
云栖号资讯:【 点击查看更多行业资讯 】 在这里您可以找到不同行业的第一手的上云资讯,还在等什么,快来! 导读: 随着Python的停滞不前,一个新的热门竞争对手崛起了。 如果Julia对你来说仍是个谜,别担心。 不要误会我的意思。Python的流行仍然受到计算机科学家、数据科学家、人工智能专家,以及他们组成的稳固社区的坚定支持。 但是,如果你曾经和这些人一起共进过晚餐,那么你就应该知道他们对于Python的弱点有多少抱怨。从速度缓慢到需要过多的测试,再到尽管进行了先前的测试仍然会产生很多运行时错误 - 这些已经足够让人恼火了。 这就是为什么越来越多的程序员开始采用其他语言的原因,这些语言中最受欢迎的是Julia、Go和Rust。Julia非常适合数学和技术任务,Go非常适合模块化程序,而Rust是系统编程的首选。 由于数据科学家和人工智能专家需要处理许多数学问题,因此Julia成为他们的赢家。即使经过严格的审视,Julia仍然具有Python无法战胜的优势。 01 Python的禅与Julia的贪婪 当人们创建一种新的编程语言时,他们这样做的目的是希望保留旧语言中的好特性,并修复其坏特性。 从这个意义上讲,Guido van Rossum在20世纪80年代后期创建Python的目的是为了改进ABC(Abstract Base Class - 抽象基类)

原来python还可以这样处理文件

你说的曾经没有我的故事 提交于 2020-07-24 17:13:03
首先我为大家介绍一下python语言吧! Python 是一个高层次的结合了解释性、编译性、互动性和面向对象的脚本语言。 Python 的设计具有很强的可读性,相比其他语言经常使用英文关键字,其他语言的一些标点符号,它具有比其他语言更有特色语法结构。 Python 是一种解释型语言: 这意味着开发过程中没有了编译这个环节。类似于PHP和Perl语言。 Python 是交互式语言: 这意味着,您可以在一个 Python 提示符 >>> 后直接执行代码。 Python 是面向对象语言: 这意味着Python支持面向对象的风格或代码封装在对象的编程技术。 Python 是初学者的语言: Python 对初级程序员而言,是一种伟大的语言,它支持广泛的应用程序开发,从简单的文字处理到 WWW 浏览器再到游戏。 在这个信息繁琐的时代,我们日常生活中可能每天都必须要处理大量的文件,我接下来将为大家讲解怎样用python删除指定文件类型。 文件夹路径,子文件夹路径,文件列表 os.walk(): 文件 文件.name.endswith(): os.remove(文件夹路径++() 以上的代码就是删除文件夹里面所有的指定文件类型,我删除的是表格 类型的文档,只需要修改 for 文件夹路径,子文件夹路径,文件列表 in os.walk( "E:\open" ): 里面的文件夹存放路径和 文件.name

MySql脚本

感情迁移 提交于 2020-07-24 09:13:24
#!/bin/bash A() { file="/root/mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz" if [ ! -f "$file" ]; then echo "mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz does not exist,need Upload it to /root directory" exit 0 else echo "mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz is exist!!!" fi if [ `whoami` != "root" ];then echo "root is no" exit 0 else echo "root is ok" fi a=`cat /etc/redhat-release |awk 'NR==1' | awk -F '[ ]+' '{print $4}'| cut -d . -f 1` if [ $a != "7" ];then echo "centos7.X is no" exit 0 else echo "centos7.X ok" fi } IPtables() { systemctl stop firewalld.service systemctl disable firewalld

Heat Map using Chart::Gnuplot Perl

*爱你&永不变心* 提交于 2020-07-22 21:44:19
问题 I was trying to create something like But I was not able to get the x and y axis tics coming in I tried something like this to see if the x axis tics are coming my @data = ( [0, 0, 10], [0, 1, 10], [0, 2, 10], [], [1, 0, 10], [1, 1, 5], [1, 2, 10], [], [2, 0, 10], [2, 1, 1], [2, 2, 10], [], [3, 0, 10], [3, 1, 0], [3, 2, 10], ); my $chart = Chart::Gnuplot->new( output => "test1.png", title => "3D plot from arrays of x, y and z coordinates", xlabel => 'x', ylabel => 'y', xtics => { labels => ['

Heat Map using Chart::Gnuplot Perl

℡╲_俬逩灬. 提交于 2020-07-22 21:41:25
问题 I was trying to create something like But I was not able to get the x and y axis tics coming in I tried something like this to see if the x axis tics are coming my @data = ( [0, 0, 10], [0, 1, 10], [0, 2, 10], [], [1, 0, 10], [1, 1, 5], [1, 2, 10], [], [2, 0, 10], [2, 1, 1], [2, 2, 10], [], [3, 0, 10], [3, 1, 0], [3, 2, 10], ); my $chart = Chart::Gnuplot->new( output => "test1.png", title => "3D plot from arrays of x, y and z coordinates", xlabel => 'x', ylabel => 'y', xtics => { labels => ['

Alternate looping nested foreach loops

♀尐吖头ヾ 提交于 2020-07-22 07:16:51
问题 I am trying to print a value from one foreach loop. Then go to the other foreach loop and continue until the last elements in both arrays. @list = (10, 20, 30, 40, 50); @list1 = (15, 25, 35, 45, 55); OUTER:foreach $a (@list) { print "value of a: $a\n"; foreach $b (@list1) { print "value of b: $b\n"; next OUTER; } } This returns the same value from the second foreach loop. value of a: 10 value of b: 15 value of a: 20 value of b: 15 value of a: 30 value of b: 15 value of a: 40 value of b: 15

ORA-01795: maximum number of expressions in a list is 1000 error in perl script

倖福魔咒の 提交于 2020-07-22 05:42:25
问题 I'm trying to run a query with NOT IN clause like: SELECT * FROM table WHERE column NOT IN (?,?,...) (>1000 items) and I'm getting ORA-01795: maximum number of expressions in a list is 1000 error. In my script I'm doing something like: my $lparam = join ', ' => ('?') x @ids; $lquery = "SELECT * FROM table WHERE column NOT IN ($lparam)"; $lcsr = $zdb->prepare($lquery); $lcsr->execute( @ids ); I want to split the NOT IN clause to something like where (A not in (a,b,c) AND A not in (d,e,f)) ...

How do I avoid double UTF-8 encoding in XML::LibXML

雨燕双飞 提交于 2020-07-21 07:39:07
问题 My program receives UTF-8 encoded strings from a data source. I need to tamper with these strings, then output them as part of an XML structure. When I serialize my XML document, it will be double encoded and thus broken. When I serialize only the root element, it will be fine, but of course lacking the header. Here's a piece of code trying to visualize the problem: use strict; use diagnostics; use feature 'unicode_strings'; use utf8; use v5.14; use encoding::warnings; binmode(STDOUT, "

Why do I get the first capture group only?

耗尽温柔 提交于 2020-07-21 06:00:14
问题 (https://stackoverflow.com/a/2304626/6607497 and https://stackoverflow.com/a/37004214/6607497 did not help me) Analyzing a problem with /proc/stat in Linux I started to write a small utility, but I can't get the capture groups the way I wanted. Here is the code: #!/usr/bin/perl use strict; use warnings; if (open(my $fh, '<', my $file = '/proc/stat')) { while (<$fh>) { if (my ($cpu, @vals) = /^cpu(\d*)(?:\s+(\d+))+$/) { print "$cpu $#vals\n"; } } close($fh); } else { die "$file: $!\n"; } For

Change first key of multi-dimensional Hash in perl

我的梦境 提交于 2020-07-21 03:09:10
问题 I have a multi-dimensional hash in perl and I would like to change the first key for a chosen value. For example, I have the hash my %Hash1; $Hash1{1}{12}=1; $Hash1{1}{10}=1; $Hash1{2}{31}=1; $Hash1{3}{52}=1; $Hash1{3}{58}=1; $Hash1{4}{82}=1; $Hash1{4}{154}=1; Now I want to replace the value 3 in the first key with the value 300. After this I would get: $Hash1{1}{12}=1; $Hash1{1}{10}=1; $Hash1{2}{31}=1; $Hash1{300}{52}=1; $Hash1{300}{58}=1; $Hash1{4}{82}=1; $Hash1{4}{154}=1; I know I could