会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133614个问题
JAVA 全系列/第六阶段:项目管理与SSM框架/Mybatis 18244楼
人工智能/第七阶段:机器学习-无监督学习(旧)/EM算法和GMM高斯混合模型 18245楼
JAVA 全系列/第一阶段:AI驱动的JAVA编程/数组和数据存储 18246楼

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/index.css">
</head>
<body>

<div class="container" style="width: 500px">
    <div class="row">
        <!--one-->
        <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
            <div class="carousel-inner">
                <div class="carousel-item active">
                    <img src="http://code.z01.com/img/2016instbg_01.jpg" class="d-block w-100" alt="...">
                </div>
                <div class="carousel-item">
                    <img src="http://code.z01.com/img/2016instbg_02.jpg" class="d-block w-100" alt="...">
                </div>
                <div class="carousel-item">
                    <img src="http://code.z01.com/img/2016instbg_03.jpg" class="d-block w-100" alt="...">
                </div>
            </div>
            <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                <span class="sr-only">Previous</span>
            </a>
            <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="sr-only">Next</span>
            </a>
        </div>
    </div>
    <div class="row">
        <!--        two-->
        <div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
            <div class="carousel-indicators">
                <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active"
                        aria-current="true" aria-label="Slide 1"></button>
                <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1"
                        aria-label="Slide 2"></button>
                <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2"
                        aria-label="Slide 3"></button>
            </div>
            <div class="carousel-inner">
                <div class="carousel-item active">
                    <img src="./images/1.jpg" class="d-block w-100" alt="...">
                </div>
                <div class="carousel-item">
                    <img src="./images/3.jpg" class="d-block w-100" alt="...">
                </div>
                <div class="carousel-item">
                    <img src="./images/2.jpg" class="d-block w-100" alt="...">
                </div>
            </div>
            <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators"
                    data-bs-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                <span class="visually-hidden">Previous</span>
            </button>
            <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators"
                    data-bs-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="visually-hidden">Next</span>
            </button>
        </div>
    </div>
</div>
<script src="js/jquery-1.12.4.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>



image.png


老师,第二个例子是复制的bootstrap官网上的轮播图,但是效果并没有达到,第一个是文档中的,二者并没有差距,但实现效果为何不同呢?而且官网很多都实现不了,是什么原因?



WEB前端全系列/第四阶段:BootStrap框架模块/BootStrap4实战 18247楼
JAVA 全系列/第二十二阶段:分布式医疗云平台/系统管理前后端开发(旧) 18248楼
JAVA 全系列/第二十四阶段:容器管理技术/Docker 18249楼

node_list = [
    {'data':'A','left':'B','right':'C','is_root':True},
    {'data':'B','left':'D','right':'E','is_root':False},
    {'data':'D','left':'None','right':'None','is_root':False},
    {'data':'E','left':'H','right':'None','is_root':False},
    {'data':'H','left':'None','right':'None','is_root':False},
    {'data':'C','left':'F','right':'G','is_root':False},
    {'data':'F','left':'None','right':'None','is_root':False},
    {'data':'G','left':'I','right':'J','is_root':False},
    {'data':'I','left':'None','right':'None','is_root':False},
    {'data':'J','left':'None','right':'None','is_root':False}
]
class Node:
    def __init__(self,data,left=None,right=None):
        self.data,self.right,self.left = data,right,left

class Tree:
    def __init__(self,root=None):
        self.root = root
    def init_data(self,datas):
        node_dict = {}
        for d in datas:
            node = Node(d['data'],d['left'],d['right'])
            node_dict[d['data']] = node
        for d in datas:
            node = node_dict[d['data']]
            if node.left:
                node.left = node_dict[node.left]
            if node.right:
                node.right = node_dict[node.right]
            if d['is_root']:
                self.root= node
    def iter_node1(self,node):
        if node:
            print(node.data)
            self.iter_node1(node.left)
            self.iter_node1(node.right)
    def iter_node2(self,node):
        node_list = [node]
        for n in node_list:
            print(n.data)
            if n.left:
                node_list.append(n.left)
            if n.right:
                node_list.append(n.right)
    def reverse(self,node):
        if node:
            node.left,node.right = node.right,node.left
            self.reverse(node.left)
            self.reverse(node.right)

if __name__ == '__main__':
    tree = Tree()
    tree.init_data(node_list)
    tree.reverse(tree.root)
    # tree.iter_node1(tree.root)
    tree.iter_node2(tree.root)

image.png

老师,错在哪里?没看出来

Python 全系列/第十七阶段:数据结构与算法/算法与数据结构(旧) 18250楼
JAVA 全系列/第十一阶段:分布式RPC调用和分布式文件存储/Dubbo 18251楼

源代码:

package com.bjsxt.TcpIp;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class InetDemo02 {
    public static void main(String[] args) throws UnknownHostException {

        InetAddress inetAddress1 = InetAddress.getByName("www.baidu.com");

        byte[] bytes1 = inetAddress1.getAddress();
        System.out.print("inetAddress1.getAddress(): ");
        for (byte b : bytes1) {
            System.out.print(b + ",");
        }
        System.out.println();
        System.out.println("inetAddress1.getHostAddress(): " + inetAddress1.getHostAddress());
        System.out.println("inetAddress1.getHostName(): " + inetAddress1.getHostName());
        System.out.println("=====================================");
        InetAddress inetAddress2 = InetAddress.getByAddress(bytes1);
        System.out.println("inetAddress2.getHostAddress(): " + inetAddress2.getHostAddress());
        System.out.println("inetAddress2.getHostName(): " + inetAddress2.getHostName());
        System.out.println("=====================================");
    }
}

运行结果:

inetAddress1.getAddress(): -73,-24,-25,-82,
inetAddress1.getHostAddress(): 183.232.231.174
inetAddress1.getHostName(): www.baidu.com
=====================================
inetAddress2.getHostAddress(): 183.232.231.174
inetAddress2.getHostName(): 183.232.231.174
=====================================

疑问:

为什么 inetAddress2.getHostName() 获取的不是“www.baidu.com”呢?

 inetAddress2是通过 getByAddress 获取的,用的就是 inetAddress1 的 getAddress 的返回值,我以为应该指向是相同的,实际运行获取的 getHostAddress() 相同,但是获取的 getHostName() 不同。

通过getByAddress(), 要填入什么参数,才能有 getHostName() 来获得 "www.baidu.com"呢?


JAVA 全系列/第二阶段:JAVA 基础深化和提高/网络编程(旧) 18252楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637